package com.g8.pethospitallearnbackend.mapper;

import com.g8.pethospitallearnbackend.entity.Charge;
import com.g8.pethospitallearnbackend.entity.ChargeExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface ChargeMapper {
    @SelectProvider(type=ChargeSqlProvider.class, method="countByExample")
    long countByExample(ChargeExample example);

    @DeleteProvider(type=ChargeSqlProvider.class, method="deleteByExample")
    int deleteByExample(ChargeExample example);

    @Delete({
        "delete from charge",
        "where charge_id = #{chargeId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String chargeId);

    @Insert({
        "insert into charge (charge_id, charge_name, ",
        "charge_price, charge_desc)",
        "values (#{chargeId,jdbcType=VARCHAR}, #{chargeName,jdbcType=VARCHAR}, ",
        "#{chargePrice,jdbcType=DOUBLE}, #{chargeDesc,jdbcType=LONGVARCHAR})"
    })
    int insert(Charge record);

    @InsertProvider(type=ChargeSqlProvider.class, method="insertSelective")
    int insertSelective(Charge record);

    @SelectProvider(type=ChargeSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="charge_id", property="chargeId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="charge_name", property="chargeName", jdbcType=JdbcType.VARCHAR),
        @Result(column="charge_price", property="chargePrice", jdbcType=JdbcType.DOUBLE),
        @Result(column="charge_desc", property="chargeDesc", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Charge> selectByExampleWithBLOBs(ChargeExample example);

    @SelectProvider(type=ChargeSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="charge_id", property="chargeId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="charge_name", property="chargeName", jdbcType=JdbcType.VARCHAR),
        @Result(column="charge_price", property="chargePrice", jdbcType=JdbcType.DOUBLE)
    })
    List<Charge> selectByExample(ChargeExample example);

    @Select({
        "select",
        "charge_id, charge_name, charge_price, charge_desc",
        "from charge",
        "where charge_id = #{chargeId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="charge_id", property="chargeId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="charge_name", property="chargeName", jdbcType=JdbcType.VARCHAR),
        @Result(column="charge_price", property="chargePrice", jdbcType=JdbcType.DOUBLE),
        @Result(column="charge_desc", property="chargeDesc", jdbcType=JdbcType.LONGVARCHAR)
    })
    Charge selectByPrimaryKey(String chargeId);

    @UpdateProvider(type=ChargeSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Charge record, @Param("example") ChargeExample example);

    @UpdateProvider(type=ChargeSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Charge record, @Param("example") ChargeExample example);

    @UpdateProvider(type=ChargeSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Charge record, @Param("example") ChargeExample example);

    @UpdateProvider(type=ChargeSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Charge record);

    @Update({
        "update charge",
        "set charge_name = #{chargeName,jdbcType=VARCHAR},",
          "charge_price = #{chargePrice,jdbcType=DOUBLE},",
          "charge_desc = #{chargeDesc,jdbcType=LONGVARCHAR}",
        "where charge_id = #{chargeId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKeyWithBLOBs(Charge record);

    @Update({
        "update charge",
        "set charge_name = #{chargeName,jdbcType=VARCHAR},",
          "charge_price = #{chargePrice,jdbcType=DOUBLE}",
        "where charge_id = #{chargeId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Charge record);
}